Slides: OpenOffice
PowerPoint
Reading: HFJS Ch. 6
Tools
JavaScript helper functions for cookie handling: cookie.js
XHTML to PDF translator:
Prince 8.0 download.
Preliminary project pages due last Tuesday. Preliminary summary.pdf files due today.
Demonstration
Modify the
convert.html page from last week
to converts arbitrary decimal integers to hexidecimal Strings.
- Respond to changes in the decimal field.
- Complain, if the user enters something that is not a number.
- Create a function to convert integers from 0 to 15 to a hexidecimal character.
-
Repeatedly,
- take the remainder of the input integer mod 16,
- convert this remainder to a hexidecimal character,
- prepend this character to a result string that starts off being empty, and
- divide the input by 16,
as long as the input is greater than zero.
- Prepend the characters
0x
to your result String
- Display your result in the hexidecimal field
- Handle zero input correctly.
- Handle negative decimal input correctly.
Lab
- Create a directory inside the
Labs
directory on your thumbdrive for today's lab.
-
Modify the convert.html file from the demonstration
to convert from a hexidecimal String back to a decimal integer.
-
Respond to changes in the hexidecimal field.
Create a function convertToDecimal() to handle this.
-
Complain, if the user enters something that doesn't begin with the String
0x
and then return.
(Do something similar if ever you detect that the user's input is bogus.)
- Create a function that turns a hexidecimal character into an integer from 0 to 15.
- Remove the first two characters (
0x
) from the input.
- Creat a variable result and set it to zero.
-
Repeatedly,
- multiply result by 16.
- remove the first input character,
- convert it to a number,
- add this number to result,
as long as the input has more characters.
- Convert your result to a String and display it in the decimal field
- Handle zero input correctly.
- Handle negative decimal input correctly.
-
Add links to the files from today's lab to the index.html file in your
Labs
directory.
- Using FileZilla (or another FTP client), synchronize your website to the image on your thumbdrive.
Always shut down your computer and turn off your display before leaving the lab.